﻿using CDV.MC.WebAPI.TaskExecution.Filter;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CDV.MC.WebAPI.TaskExecution.Controllers
{
    /// <summary>
    /// 任务路由执行API
    /// </summary>
    [Route("api/exec")]
    [ValidateModel]
    public class TaskExecutionController : Controller
    {
        /// <summary>
        /// 获取任务路由列表
        /// </summary>
        /// <param name="beginTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns>任务路由列表</returns>
        [HttpGet]
        public IActionResult List(DateTime beginTime, DateTime endTime)
        {
            return Ok(new List<string>() { "list1", "list2" });
        }

        /// <summary>
        /// 路由确认
        /// </summary>
        /// <remarks>
        /// Sample Request：
        ///     api/exec/confirm/12345
        ///     
        /// Returns：
        ///     RouteID：路由ID
        ///     ErrorMsg：错误信息
        /// </remarks>
        /// <param name="routeID">路由ID</param>
        /// <returns>(路由ID,路由确认的反馈)</returns>
        /// <response code="400">路由ID小于等于0</response>
        [HttpGet("confirm/{routeID}")]
        [ProducesResponseType(400)]
        public IActionResult Confirm(int routeID)
        {
            return new JsonResult(new { RouteID = routeID, ErrorMsg = "" });
        }

        /// <summary>
        /// 路由执行
        /// </summary>
        /// <param name="routeID">路由ID</param>
        /// <returns>(路由ID,路由执行的反馈)</returns>
        /// <response code="400">路由ID小于等于0</response>
        [HttpGet("execute/{routeID}")]
        public IActionResult Execute(int routeID)
        {
            return new JsonResult(new { RouteID = routeID, ErrorMsg = "" });
        }

        /// <summary>
        /// 结束路由执行
        /// </summary>
        /// <param name="routeID">路由ID</param>
        /// <returns>(路由ID,结束路由执行的反馈)</returns>
        /// <response code="400">路由ID小于等于0</response>
        [HttpPut("finish/{routeID}")]
        public IActionResult Finish(int routeID)
        {
            return new JsonResult(new { RouteID = routeID, ErrorMsg = "" });
        }

        /// <summary>
        /// 路由应急切
        /// </summary>
        /// <param name="routeID">路由ID</param>
        /// <returns>(路由ID,路由应急切的反馈)</returns>
        /// <response code="400">路由ID小于等于0</response>
        [HttpGet("take/{routeID}")]
        public IActionResult ForceTake(int routeID)
        {
            return new JsonResult(new { RouteID = routeID, ErrorMsg = "" });
        }

        /// <summary>
        /// 路由复位
        /// </summary>
        /// <param name="routeID">路由ID</param>
        /// <returns>(路由ID,路由复位的反馈)</returns>
        /// <response code="400">路由ID小于等于0</response>
        [HttpGet("reset/{routeID}")]
        public IActionResult Reset(int routeID)
        {
            return new JsonResult(new { RouteID = routeID, ErrorMsg = "" });
        }
    }
}
